#ifndef UIAVATARWIDGET_H
#define UIAVATARWIDGET_H

#include "data/avatar_factory.h"
#include <QLabel>
#include <QMovie>
#include <QVBoxLayout>
#include <QWidget>

class Avatar;

class UiAvatarWidget : public QWidget
{
    Q_OBJECT
public:
    explicit UiAvatarWidget(QWidget *parent = nullptr);
    ~UiAvatarWidget();

    void SetAvatarType(const int& type);
    void SetAvatarTypeCustom(QMap<QString,QString> res_map, bool is_gif = false);
    void SetMovie(const QString& avatar_status);

    void SetGifPlayTimes(const int& play_mode);

public:
    enum enum_avatar_type{
        ENUM_AVATAR_CUSTOM = -1,
        ENUM_AVATAR_EVIL = 0,
        ENUM_AVATAR_ANGEL,
        ENUM_AVATAR_ACTOR,
    };

signals:

private:
    QLabel*      avatar_label_;
    QVBoxLayout* v_box_layout_;

    QMovie      final_avatar_gif_;
    QImage      final_avatar_img_;

    int          avatar_type_;
    int          play_mode_ = 0;
    bool         is_gif_ = true;
    Avatar*      current_avatar_;

private:
    inline void ClearAvatarMovie(){if(current_avatar_ != nullptr) current_avatar_->ClearMovie();}
    inline void ClearAvatarImage(){if(current_avatar_ != nullptr) current_avatar_->ClearImage();}
    inline void ClearAvatar(){if(current_avatar_ != nullptr) current_avatar_->ClearAll();}
    void ClearFinalAvatarImage();
    void ClearFinalAvatarMovie();
    void ClearAll();

private slots:
    void slot_play_control(int frame_number);

};

#endif // UIAVATARWIDGET_H
